import { defineConfig } from 'vite'
import { resolve } from 'path'
import vue from '@vitejs/plugin-vue'
import windicss from 'vite-plugin-windicss'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      resolvers:[ElementPlusResolver()],
    }),
    Components({
      resolvers:[ElementPlusResolver()],
    }),
    windicss(),
  ],
  resolve:{
    alias:{
      '@':resolve('src')
    }
  },
  //配置跨域
  server:{
    host:'localhost',
    open:true,
    port:8080,
    proxy:{
      '/api':{
        target:'http://localhost:3000',
        changeOrigin:true,//允许跨域 
        // rewrite:(path)=>path.replace(/^\/api/,'')
      }
    }
  }
})
